// 控制面板模块


// 页面渲染加载时启动
document.addEventListener('DOMContentLoaded', function() {
    restoreOptions();
});

// 读取存储中的状态，并更新页面
function restoreOptions() {
    chrome.storage.sync.get({
        closeForm: false,
        Cancelcountdown: false,
        Answerassistant: false,
        Show: false
    }, function(items) {
        document.getElementById('closeForm').checked = items.closeForm ? true : false;
        document.getElementById('Cancelcountdown').checked = items.Cancelcountdown ? true : false;
        document.getElementById('Answerassistant').checked = items.Answerassistant ? true : false;
        document.getElementById('Show').checked = items.Show ? true : false;
    });
}

// 监听复选框的点击事件，并更新存储中的状态
document.getElementById('closeForm').addEventListener('change', function() {
    var closeFormChecked = this.checked;
    chrome.storage.sync.set({ closeForm: closeFormChecked });
});
document.getElementById('Cancelcountdown').addEventListener('change', function() {
    var closeFormChecked = this.checked;
    chrome.storage.sync.set({ Cancelcountdown: closeFormChecked });
});
document.getElementById('Answerassistant').addEventListener('change', function() {
    var closeFormChecked = this.checked;
    chrome.storage.sync.set({ Answerassistant: closeFormChecked });
});
document.getElementById('Show').addEventListener('change', function() {
    var closeFormChecked = this.checked;
    chrome.storage.sync.set({ Show: closeFormChecked });
});


